<template>
  <div class="body">
      <div class="params-row" id="parent" @click="changeBackgroundColor">
          <div class="bg-box">none</div>
          <div>form-data</div>
          <div>x-www-form-urlencoded</div>
          <div>json</div>
          <div>xml</div>
      </div>
      <div class="no-body">
          <div class="no-body-img" v-if="value=='none'">
              <img src="@/assets/images/Empty Inbox _Monochromatic.svg" alt="">
          </div>
          <div class="from" v-else-if="value=='form-data'">
              <TmTable />
          </div>
          <div class="from" v-else-if="value=='x-www-form-urlencoded'">
              <TmTable />
          </div> 
          <div class="text" v-else-if="value=='json'">
             <el-input type="textarea" v-model="textarea"></el-input>
          </div>
      </div>
      
  </div>
</template>
  
<script setup lang='ts'>
import { ref } from "vue";
import TmTable from '@/components/Ym-table/index.vue';
const value = ref('none')
const textarea = ref('')
//点击切换背景颜色
const changeBackgroundColor = (event: any) => {
  const parent = document.getElementById("parent");
  const children = parent.querySelectorAll("div");
  //清除样式
  children.forEach((item: Element) => {
      item.classList.remove("bg-box");
  });
  event.target.classList.add("bg-box");
  value.value = event.target.innerText;
  console.log(value.value);
  
}
</script>
  
<style scoped lang="scss">
.body {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;

  .params-row {
      height: 40px;
      width: 100%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      margin-bottom: 10px;

      div {
          box-sizing: content-box;
          padding: 5px;
          height: 24px;
          line-height: 24px;
          font-size: 21px;
          color: #707070;
          margin-left: 20px;
      }

      //蓝色背景
      .bg-box {
          border-left: #aed9e0 10px solid;
          border-right: #aed9e0 10px solid;
          background-color: #aed9e0;
          border-radius: 5px;
          color: #fff;
          transition:  0.3s linear;
      }
  }

  .no-body {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;

      .no-body-img {
          width: 220px;
          height: 183px;

          img {
              width: 100%;
              height: 100%;
          }
      }
      .from,.text {
          width: 100%;
          height: 100%;    
      }
      .from {
          padding-left: 15px;
      }
      .text {
          padding: 0 10px 10px 10px;
          box-sizing: border-box;
         
          .el-textarea {
              height: 100%; 
          }
          :deep(.el-textarea_inner){
            height: 100%;
          }
      }
  }
}

//请求字体
.font-body {
  width: 100%;
  text-align: center;
  font-size: 27px;
  color: #707070;
}
</style>